<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>毕业设计项目</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<script type="text/javascript" src="../../js/jquery-1.9.0.js"></script>
<link href="../../css/style.css" rel="stylesheet" type="text/css">
<script src="../../script/common.js"></script>
</head>
<body onload="getLinkmen()">

<div class="page_title">客户信息管理 > 客户信息 > 联系人 > 编辑联系人</div>
<div class="button_bar">
	<button class="common_button" onclick="help('');">帮助</button>
	<button class="common_button" onclick="back();">返回</button>
	<button class="common_button" onclick="updateLinkmen()">保存</button>
</div>
<table class="query_form_table" id="table1">

</table>
</body>
</html>
<script type="text/javascript">
    function UrlSearch(){
        var str=location.href; //取得整个地址栏
        var num=str.indexOf("=")
        str=str.substr(num+1); //取得所有参数   stringvar.substr(start [, length ]
        return str;
    }
	function getLinkmen() {
        UrlSearch()
        var lkmId=UrlSearch();
//        alert(lkmId);
        $.ajax({
            url: "/CstLinkman/selectCstLinkmanForId",
            type: 'GET',
            data:{"lkmId":lkmId},
            dataType: 'json',
            contentType: "application/json;charset=utf-8",
            success:function (cstLinkmanForId) {
                var sex="";
                if(cstLinkmanForId.lkmSex=="男"){
					sex='<input type="radio" name="lkmSex" value="'+cstLinkmanForId.lkmSex+'"  checked />男'+
                        '<input type="radio" name="lkmSex" value="'+cstLinkmanForId.lkmSex+'" />女'
				}
                if(cstLinkmanForId.lkmSex=="女"){
                    sex='<input type="radio" name="lkmSex" value="'+cstLinkmanForId.lkmSex+'"   />男'+
                        '<input type="radio" name="lkmSex" value="'+cstLinkmanForId.lkmSex+'" checked/>女'
                }
                console.info(cstLinkmanForId);
				var linkmenTable='	<tr>'+
				 '<th>姓名</th>'+
				 '<td><input readonly name="lkmName" value="'+cstLinkmanForId.lkmName+'" size="20" /><span class="red_star">*</span></td>'+
				 '<th>性别</th>'+
				 '<td>'+
				 	sex+
				 '</td>'+
				 '</tr>'+
				 '<tr>'+
				 '<th>职位</th>'+
				 '<td><input name="lkmPostion" value="'+cstLinkmanForId.lkmPostion+'" size="20" /><span class="red_star">*</span></td>'+
				 '<th>办公电话</th>'+
				 '<td><input name="lkmTel" value="'+cstLinkmanForId.lkmTel+'" size="20" /><span class="red_star">*</span></td>'+
				 '</tr>'+
				 '<tr>'+
				 '<th>手机</th>'+
				 '<td><input name="lkmMobile" value="'+cstLinkmanForId.lkmMobile+'" size="20" /></td>'+
				 '<th>备注</th>'+
				 '<td><input name="lkmMemo" value="'+cstLinkmanForId.lkmMemo+'" size="20" /></td>'+
				 '</tr>';
				$("#table1").append(linkmenTable);
            }
        });
    }
	function updateLinkmen() {
		var lkmName=$("input[name=lkmName]").val();
		var lkmSex=$("input[name=lkmSex]").val();
		var lkmPostion=$("input[name=lkmPostion]").val();
		var lkmTel=$("input[name=lkmTel]").val();
		var lkmMobile=$("input[name=lkmMobile]").val();
		var lkmMemo=$("input[name=lkmMemo]").val();
		$.ajax({
            url: "/CstLinkman/updateCstLinkman",
            type: 'GET',
            data: {
                "lkmName": lkmName,
                "lkmSex": lkmSex,
                "lkmPostion": lkmPostion,
                "lkmTel": lkmTel,
                "lkmMobile": lkmMobile,
                "lkmMemo": lkmMemo
            },
            dataType: 'json',
            contentType: "application/json;charset=utf-8",
            success:function (i) {
				if(i>0){
				    alert("更新成功,请点击返回");
                    window.location.reload();
//                    window.history.back();
				}
            }
		});
    }
</script>